<template>
  <div>
    <div class="search-pad">
      <input
        type="text"
        name=""
        id=""
        @focus="searchFocus()"
        @blur="searchBlur()"
      />
      <button v-show="isShowSearchBtn">搜索</button>
      <button v-show="!isShowSearchBtn" @click="showRight()">筛选</button>
    </div>
    <div class="system-pad">
      <div
        :class="['system-item', { 'system-select': systemIndex == 1 }]"
        @click="getSystemProduct(1)"
      >
        <span>板材</span>
      </div>
      <div
        :class="['system-item', { 'system-select': systemIndex == 2 }]"
        @click="getSystemProduct(2)"
      >
        <span>五金</span>
      </div>
      <div
        :class="['system-item', { 'system-select': systemIndex == 3 }]"
        @click="getSystemProduct(3)"
      >
        <span>地板</span>
      </div>
    </div>
    <div class="product-list">
      <ul>
        <li>
          <img src="" alt="" />
          <div>
            <p class="p-name">五金架子做垫板</p>
            <p class="p-type">类别：处理</p>
            <p class="p-price">&yen;0.00/张</p>
          </div>
        </li>
        <li>
          <img src="" alt="" />
          <div>
            <p class="p-name">五金架子做垫板</p>
            <p class="p-type">类别：处理</p>
            <p class="p-price">&yen;0.00/张</p>
          </div>
        </li>
      </ul>

      <div :class="['left-menu', { 'left-menu-show': isShowLeft }]">
        <div class="left-switch" @click="showLeft()">
          <img src="/img/dealerImgs/up.png" alt="" />
        </div>
        <ul>
          <li>免漆板背板</li>
          <li>免漆板</li>
          <li>面板</li>
          <li class="left-item-select">木工板</li>
          <li>木工板</li>
          <li>木工板</li>
          <li>免漆板背板</li>
          <li>免漆板</li>
          <li>面板</li>
          <li>木工板</li>
          <li>木工板</li>
          <li>木工板</li>
          <li>免漆板背板</li>
          <li>免漆板</li>
          <li>面板</li>
          <li>木工板</li>
          <li>木工板</li>
          <li>木工板</li>
        </ul>
      </div>
    </div>
    <div class="right-pad">
      <ul class="f-type-list">
        <li>
          <p>颜色</p>
          <ul class="f-item-list">
            <li><span>胡桃色</span></li>
            <li><span class="prop-select">胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
          </ul>
          <div class="clear-tag"></div>
        </li>
        <li>
          <p>颜色</p>
          <ul class="f-item-list">
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
          </ul>
          <div class="clear-tag"></div>
        </li>
        <li>
          <p>颜色</p>
          <ul class="f-item-list">
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
            <li><span>胡桃色</span></li>
          </ul>
          <div class="clear-tag"></div>
        </li>
      </ul>
      <div class="right-edit">
        <button
          @click="confirmFilter()"
          style="background-color: rgb(188, 0, 0); color: #fff"
        >
          确定
        </button>
        <button @click="hideRight()">取消</button>
      </div>
    </div>
    <div class="cover" v-show="isShowCover" @click="hideRight()"></div>
  </div>
</template>

<script>
import { onMounted, ref } from "vue";
import { getProduct, getProductlist } from "../HttpRequests/ProductlistRequest";
export default {
  setup() {
    const systemIndex = ref(1);
    const isShowLeft = ref(false);
    const isShowCover = ref(false);
    const isShowSearchBtn = ref(false);

    const getSystemProduct = (index) => {
      systemIndex.value = index;
    };
    const showLeft = () => {
      isShowLeft.value = !isShowLeft.value;
    };
    const searchFocus = () => {
      isShowSearchBtn.value = true;
    };
    const searchBlur = () => {
      isShowSearchBtn.value = false;
    };
    const confirmFilter = () => {};

    const showRight = () => {
      isShowCover.value = true;
      document.querySelector(".right-pad").style.right = "0";
    };
    const hideRight = () => {
      isShowCover.value = false;
      document.querySelector(".right-pad").style.right = "-85%";
    };
    onMounted(async () => {
     var product= await getProduct(
         blongType="BC",
         pageIndex=1
     );
     console.log(product);
    });

    return {
      systemIndex,
      isShowLeft,
      isShowCover,
      isShowSearchBtn,
      getSystemProduct,
      showLeft,
      searchFocus,
      searchBlur,
      confirmFilter,
      showRight,
      hideRight,
    };
  },
};
</script>

<style lang="scss" scoped>
.i-search:after {
  background-color: #b70101 !important;
}

.search-pad {
  padding: 6px 20px;
  background-color: #f0f0f0;
  display: flex;

  input {
    height: 28px;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 3px;
    flex: 1;
    outline: none;
  }

  button {
    background-color: transparent;
    width: 56px;
    border: 0 none;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    outline: none;
  }
}

.system-pad {
  background-color: #fff;
  display: flex;

  .system-item {
    flex: 1;
    text-align: center;
    border-bottom: 1px #ddd solid;
    border-right: 1px transparent solid;
    border-left: 1px transparent solid;

    span {
      border: 0 none !important;
      background-color: #f0f2f5;
      margin: 6px 5px;
      font-size: 12px;
      font-weight: normal;
      text-align: center;
      border-radius: 4px;
      padding: 6px 0;
      display: block;
      height: 25px;
      line-height: 12px;
    }
  }

  .system-select {
    border-bottom: 1px transparent solid;
    border-right: 1px #ddd solid;
    border-left: 1px #ddd solid;

    span {
      background-color: transparent;
    }
  }
}

.product-list {
  ul {
    background-color: #fff;

    li {
      list-style: none;
      height: 88px;
      padding-left: 108px;
      position: relative;

      img {
        height: 66px;
        width: 66px;
        background-color: #ccc;
        position: absolute;
        left: 28px;
        top: 11px;
      }

      div {
        padding: 10px 0;
        border-bottom: 1px solid #f0f0f0;
        padding-bottom: 12px;

        .p-name {
          font-size: 13px;
        }

        .p-type {
          font-size: 12px;
          color: #666;
          margin-top: 8px;
        }

        .p-price {
          font-size: 13px;
          color: #f23030;
          margin-top: 8px;
        }
      }
    }
  }

  .left-menu {
    position: fixed;
    height: calc(100% - 116px);
    left: -106px;
    width: 125px;
    background-color: #fff;
    top: 76px;
    border-radius: 0 18px 0 0;
    border: 1px solid #d7d7d7;
    overflow: hidden;
    transition: 0.5s;
    margin-bottom: 120px;

    .left-switch {
      width: 20px;
      background-color: #fff;
      position: absolute;
      right: 0;
      height: 100%;

      img {
        position: absolute;
        top: 42%;
        width: 20px;
        transform: rotate(90deg);
        transition: 0.5s;
      }
    }

    ul {
      position: absolute;
      height: 100%;
      width: 106px;
      background-color: #f0f0f0;
      overflow: auto;

      li {
        width: 106px;
        height: 50px;
        text-align: center;
        line-height: 50px;
        border-bottom: 1px solid #d7d7d7;
        padding: 0;
        font-size: 12px;
        color: #333;
      }

      li.left-item-select {
        background-color: #fff;
      }
    }
  }

  .left-menu-show {
    left: 0;

    .left-switch {
      img {
        transform: rotate(-90deg);
      }
    }
  }
}

.right-pad {
  position: fixed;
  /* right: -85%; */
  right: -85%;
  top: 0;
  width: 85%;
  height: 100%;
  background-color: #f7f7f7;
  z-index: 103;
  transition: 580ms;
  z-index: 101;

  ul {
    list-style: none;
    overflow: hidden;
  }

  .f-type-list {
    overflow: hidden;

    > li {
      padding: 10px;
      background-color: #fff;
      margin-bottom: 10px;

      .f-item-list {
        overflow: hidden;
        display: flex;
        flex-wrap: wrap;

        li {
          flex-basis: 33.3%;

          span {
            display: block;
            margin-top: 10px;
            margin-right: 10px;
            background: #eee;
            border: 1px solid #eee;
            padding: 5px 0;
            text-align: center;
            border-radius: 6px;
            font-size: 13px;
          }

          .prop-select {
            border: 1px solid red;
            background: #fff;
            color: red;
          }
        }
      }

      p {
        font-size: 14px;
      }
    }
  }

  .right-edit {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;

    button {
      float: left;
      height: 40px;
      width: 50%;
      line-height: 40px;
      text-align: center;
      border: 0px none;
    }
  }
}

.cover {
  position: fixed;
  height: 100%;
  width: 100%;
  left: 0;
  top: 0;
  background-color: rgba(51, 51, 51, 0.36);
}
</style>
